<template>
	<view class="article" v-if="dataSource">
		<view class="image">
			<image class="images" :src="dataSource.image" mode="aspectFill"></image>
		</view>
		<view class="title">
			<view class="tip">
				<image class="tipImg" src="../../static/icon/VIP.png" mode="aspectFit"></image>
				<text class="tips">皮皮柴小贴士</text>
			</view>
			<text class="titleText">{{dataSource.title}}</text>
		</view>
		<view class="content">
			<view class="item" v-for="(item,index) in data" :key="index">
				<text>{{item}}</text>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
		onUnload
	} from '@dcloudio/uni-app'
	const dataSource = ref()
	const data = ref()
	onLoad(() => {
		uni.$on("articleData", (item) => {
			dataSource.value = item
			data.value = dataSource.value.content.split(' ')
		})
		uni.$emit('richtext1')
	})
	onUnload(() => {
		uni.$off('articleData')
	})
</script>

<style lang="scss">
	.article {
		position: relative;
		height: 100vh;

		.image {
			width: 100%;
			height: 300rpx;

			.images {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			position: absolute;
			top: 300rpx;
			left: 50%;
			width: 90%;
			height: 200rpx;
			transform: translate(-50%, -50%);
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			background: #FFF;
			border-radius: 30rpx;
			box-shadow: 0 4rpx 10rpx 0rpx #eee;

			.titleText {
				font-size: 38rpx;
				font-weight: bold;
				margin-top: 10rpx;

			}

			.tip {
				display: flex;
				align-items: center;
				justify-content: center;

				.tipImg {
					width: 30rpx;
					height: 30rpx;
				}

				.tips {
					font-size: 24rpx;
					font-weight: bold;
					color: #afafaf;
				}
			}
		}

		.content {
			height: calc(100vh - 300rpx);
			background: #FFF;
			display: flex;
			flex-direction: column;

			.item {
				text-indent: 30rpx;
				font-size: 28rpx;
				padding:10rpx 20rpx;
			}

			.item:first-child {
				padding: 150rpx 20rpx 0rpx 20rpx;
			}
		}
	}
</style>